home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / invest / __init__.pyc (.txt) next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  2.5 KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import sys
  6. from os.path import join, exists, isdir, isfile, dirname, abspath, expanduser
  7. import gtk
  8. import gtk.gdk as gtk
  9. import gconf
  10. import gobject
  11. import cPickle
  12. from defs import *
  13. DEBUGGING = False
  14. UNINSTALLED_INVEST = False
  15.  
  16. def _check(path):
  17.     if exists(path) and isdir(path):
  18.         pass
  19.     return isfile(path + '/ChangeLog')
  20.  
  21. name = join(dirname(__file__), '..')
  22. if _check(name):
  23.     UNINSTALLED_INVEST = True
  24.  
  25. if UNINSTALLED_INVEST:
  26.     SHARED_DATA_DIR = abspath(join(dirname(__file__), '..', 'data'))
  27.     BUILDER_DATA_DIR = SHARED_DATA_DIR
  28.     ART_DATA_DIR = join(SHARED_DATA_DIR, 'art')
  29. else:
  30.     SHARED_DATA_DIR = join(DATA_DIR, 'gnome-applets', 'invest-applet')
  31.     BUILDER_DATA_DIR = BUILDERDIR
  32.     ART_DATA_DIR = SHARED_DATA_DIR
  33. if DEBUGGING:
  34.     print 'Data Dir: %s' % SHARED_DATA_DIR
  35.  
  36. USER_INVEST_DIR = expanduser('~/.gnome2/invest-applet')
  37. if not exists(USER_INVEST_DIR):
  38.     
  39.     try:
  40.         os.makedirs(USER_INVEST_DIR, 484)
  41.     except Exception:
  42.         msg = None
  43.         print 'Error:could not create user dir (%s): %s' % (USER_INVEST_DIR, msg)
  44.     except:
  45.         None<EXCEPTION MATCH>Exception
  46.     
  47.  
  48. None<EXCEPTION MATCH>Exception
  49. os.chdir(expanduser('~'))
  50. GCONF_CLIENT = gconf.client_get_default()
  51. GCONF_DIR = '/apps/invest'
  52. STOCKS_FILE = join(USER_INVEST_DIR, 'stocks.pickle')
  53.  
  54. try:
  55.     STOCKS = cPickle.load(file(STOCKS_FILE))
  56. except Exception:
  57.     msg = None
  58.     STOCKS = { }
  59.  
  60. client = gconf.client_get_default()
  61.  
  62. def get_gnome_proxy(client):
  63.     if client.get_bool('/system/http_proxy/use_http_proxy'):
  64.         host = client.get_string('/system/http_proxy/host')
  65.         port = client.get_int('/system/http_proxy/port')
  66.         if host is None and host == '' or port == 0:
  67.             return None
  68.         if client.get_bool('/system/http_proxy/use_authentication'):
  69.             user = client.get_string('/system/http_proxy/authentication_user')
  70.             password = client.get_string('/system/http_proxy/authentication_password')
  71.             if user and user != '':
  72.                 url = 'http://%s:%s@%s:%d' % (user, password, host, port)
  73.             else:
  74.                 url = 'http://%s:%d' % (host, port)
  75.         else:
  76.             url = 'http://%s:%d' % (host, port)
  77.         return {
  78.             'http': url }
  79.     return None
  80.  
  81. PROXY = get_gnome_proxy(client)
  82.